# Copyright 2020 by Kurt Rathjen. All Rights Reserved.
#
# This library is free software: you can redistribute it and/or modify it 
# under the terms of the GNU Lesser General Public License as published by 
# the Free Software Foundation, either version 3 of the License, or 
# (at your option) any later version. This library is distributed in the 
# hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
# See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.

import FXstudioqt
import FXstudiolibrary


def FXmain(*args, **kwargs):
	"""
	Convenience method for creating/showing a library widget instance.

	return FXstudiolibrary.LibraryWindow.instance(
		name="",
		path="",
		show=True,
		lock=False,
		superusers=None,
		lockRegExp=None,
		unlockRegExp=None
	)

	:rtype: FXstudiolibrary.LibraryWindow
	"""
	# Reload all Studio Library modules when Shift is pressed.
	# This is for developers to test their changes in a DCC application.
	if FXstudioqt.isShiftModifier():
		import FXstudiolibrary
		FXstudiolibrary.reload()

	# Register all the items from the config file.
	import FXstudiolibrary
	FXstudiolibrary.registerItems()

	if FXstudiolibrary.isMaya():
		from FXstudiolibrarymaya import mayalibrarywindow
		libraryWindow = mayalibrarywindow.MayaLibraryWindow.instance(*args, **kwargs)
	else:
		from FXstudiolibrary import librarywindow
		libraryWindow = librarywindow.LibraryWindow.instance(*args, **kwargs)

	return libraryWindow


if __name__ == "__main__":

	# Run the Studio Library in a QApplication instance
	with FXstudiolibrary.app():
		FXstudiolibrary.FXmain()
